package com.situ.onlinebookstore.front.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.onlinebookstore.common.entity.Goods;
import com.situ.onlinebookstore.common.mapper.GoodsMapper;
import com.situ.onlinebookstore.front.service.GoodsService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class GoodsServiceImpl implements GoodsService {
private final GoodsMapper goodsMapper;
    @Override
    public List get(Goods goods) {
        return goodsMapper.select(goods);
    }

    @Override
    public PageInfo getForPage(Integer page, Integer limit, Goods goods) {
        PageHelper.startPage(page,limit);
        List list = get(goods);
        return new PageInfo(list);
    }

    @Override
    public Goods getById(Integer id) {
        return goodsMapper.selectById(id);
    }
}
